import org.antlr.runtime.*;
import java.io.*;
import java.util.Scanner;

public class YAGICommandLine{

    public static void main(String[] args) throws IOException, RecognitionException {

		Scanner scanner = new Scanner(System.in);
	        while (true) {
	            System.out.print("YAGI>> ");
	            String line = scanner.nextLine().trim();
	            if ("quit".equals(line) || "exit".equals(line))
		    	break;
		    CharStream stream = new ANTLRStringStream(line);
		    YAGILexer lexer = new YAGILexer(stream);
		    TokenStream tokenStream = new CommonTokenStream(lexer);
		    YAGIParser parser = new YAGIParser(tokenStream);
		    YAGIParser.line_return l = parser.line();
		    System.out.println(l.tree.toStringTree());
		}
    }

}